/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * EliminarPago.java
 *
 * Created on 23-may-2010, 18:42:13
 */

package ui;

import gestion.GestionSpring;
import interfaz.InterfaceEjp;
import javax.swing.JOptionPane;
import org.apache.log4j.Logger;

/**
 *
 * @author Gustavo
 */
public class EliminarPago extends javax.swing.JFrame {

    private static Logger logger = Logger.getLogger(EliminarPago.class);
    Long    Codigo;
    String Nombre;
    PaginaPrincipal miPaginaPrincipal;

    public void setMiPaginaPrincipal(PaginaPrincipal miPaginaPrincipal) {
        this.miPaginaPrincipal = miPaginaPrincipal;
        // Coloca el nombre del servicio a eliminar en pantalla
        NombrePagoEliminar.setText(Nombre);
    }

    public void setCodigo(Long Codigo) {
        this.Codigo = Codigo;
    }



    public void setNombre(String Nombre) {
        this.Nombre = Nombre;
    }

       public String getNombre() {
        return Nombre;
    }

    /** Creates new form EliminarPago */
    public EliminarPago() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        BotonSiElminar = new javax.swing.JButton();
        BotonNoEliminar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        NombrePagoEliminar = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Inversiones E.J.P");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Eliminar Producto"));
        jPanel1.setName("jPanel1"); // NOI18N

        BotonSiElminar.setText("Si");
        BotonSiElminar.setName("BotonSiElminar"); // NOI18N
        BotonSiElminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonSiElminarActionPerformed(evt);
            }
        });

        BotonNoEliminar.setText("No");
        BotonNoEliminar.setName("BotonNoEliminar"); // NOI18N
        BotonNoEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonNoEliminarActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel1.setText("¿Esta seguro que desea eliminar este pago?");
        jLabel1.setName("jLabel1"); // NOI18N

        NombrePagoEliminar.setFont(new java.awt.Font("Tahoma", 0, 14));
        NombrePagoEliminar.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        NombrePagoEliminar.setName("NombrePagoEliminar"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(20, 20, 20))
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(84, 84, 84)
                    .addComponent(BotonSiElminar)
                    .addGap(18, 18, 18)
                    .addComponent(BotonNoEliminar)
                    .addContainerGap(95, Short.MAX_VALUE)))
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(NombrePagoEliminar, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)
                    .addContainerGap()))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jLabel1)
                .addContainerGap(71, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(72, 72, 72)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(BotonSiElminar)
                        .addComponent(BotonNoEliminar))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(44, 44, 44)
                    .addComponent(NombrePagoEliminar, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(45, Short.MAX_VALUE)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-331)/2, (screenSize.height-193)/2, 331, 193);
    }// </editor-fold>//GEN-END:initComponents

    private void BotonSiElminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonSiElminarActionPerformed

      //Instanciamos la interface.
      InterfaceEjp miInterfaceEjp = GestionSpring.getSingleton().MetodoGestion();
      //Eliminarmos el pago seleccionado.
      miInterfaceEjp.EliminarPago(Codigo);
      logger.info("Eliminacion del pago con codigo: "+ Codigo);
      //Actualizamos el JTable TablaPago.
      miPaginaPrincipal.Refrescar();
      //Enviamos mensaje de exito
      JOptionPane.showMessageDialog(this, "Eliminacion exitosa");
      this.setVisible(false);
    }//GEN-LAST:event_BotonSiElminarActionPerformed

    private void BotonNoEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonNoEliminarActionPerformed
        logger.info("Salio de la pagina eliminar pago");
        this.setVisible(false);
    }//GEN-LAST:event_BotonNoEliminarActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new EliminarPago().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BotonNoEliminar;
    private javax.swing.JButton BotonSiElminar;
    private javax.swing.JLabel NombrePagoEliminar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

}
